<template>
  <div id="studentIndex">
    <!--头部-->
    <div style="height: 60px;line-height: 60px;background-color: white;margin-bottom: 2px;display: flex">
      <div style="width: 500px">
        <div style="width: 60px;height: 60px;vertical-align: middle;display: inline-block;margin-left: 10px;margin-top: -15px">
          <img src="../../assets/course.png">
        </div>
        <span style="margin-left: 10px;font-size: 24px">选课管理系统（教师端）</span>
      </div>

      <div style="flex: 1;text-align: right;padding-right: 30px">
        <div class="el-icon-user-solid" style="margin-right: 5px"></div>
        <el-dropdown size="medium" style="cursor: pointer">
        <span class="el-dropdown-link">
          {{ name }}<i class="el-icon-arrow-down el-icon--right"></i>
        </span>
          <el-dropdown-menu slot="dropdown" style="margin-top: -5px">
            <el-dropdown-item>
              <div style="width: 50px;text-align: center" @click="exit">退出</div>
            </el-dropdown-item>
          </el-dropdown-menu>
        </el-dropdown>
      </div>
    </div>

    <!--侧边栏和主体-->
    <div style="display: flex">
      <!--侧边栏-->
      <div style="width: 200px;min-height: calc(100vh - 62px);overflow: hidden;margin-right: 2px;background-color: white">
        <el-menu :default-active="$route.path" router class="el-menu-demo">
          <el-menu-item index="/teacherIndex/home">
            <i class="el-icon-house"></i>
            <span>首页</span>
          </el-menu-item>
          <el-submenu index="admin">
            <template slot="title">
              <i class="el-icon-document-copy"></i>
              <span>管理</span>
            </template>
            <el-menu-item index="/teacherIndex/giveGrade">打分</el-menu-item>
            <el-menu-item index="/teacherIndex/updateInfo">修改个人信息</el-menu-item>
            <el-menu-item index="/teacherIndex/updatePassword">修改登陆密码</el-menu-item>
          </el-submenu>
        </el-menu>
      </div>

      <!--主体-->
      <div style="width: calc(100vw - 200px);background-color: white;padding: 10px">
        <router-view/>
      </div>
    </div>
  </div>
</template>

<script>
import Cookies from "js-cookie";
import request2 from "@/utils/request2";

export default {
  name: 'TeacherIndex',
  data() {
    return {
      name: '',
      teacher: Cookies.get('teacher') ? JSON.parse(Cookies.get('teacher')) : {}
    }
  },
  created() {
    request2.get('/teacher/' + this.teacher.username).then(res => {
      this.name = res.data.tname
    })
  },
  methods:{
    exit() {
      Cookies.remove('teacher')
      this.$router.push('/login')
    }
  }
}
</script>
